{% extends "nomcom/nomcom_private_base.html" %}
{# Copyright The IETF Trust 2015-2023, All Rights Reserved #}
{% load origin static %}
{% load nomcom_tags %}
{% block subtitle %}- View feedback{% endblock %}
{% block nomcom_content %}
    {% origin %}
    <h2 class="mt-3">Feedback related to nominees</h2>
    {% regroup nominees_feedback by nominee.staterank as stateranked_nominees %}
    {% for staterank in stateranked_nominees %}
        {% if staterank.grouper == 0 %}
            <h3 class="mt-5" id="accepted">Accepted nomination for at least one position</h3>
        {% elif staterank.grouper == 1 %}
            <h3 class="mt-5" id="pending">Pending for at least one position and has not accepted any nomination</h3>
        {% else %}
            <h3 class="mt-5" id="declined">Declined each nominated position</h3>
        {% endif %}
        <table class="table table-sm table-striped tablesorter">
            <thead>
                <tr>
                    <th scope="col" data-sort="first">First name</th>
                    <th scope="col" data-sort="last">Last name</th>
                    <th scope="col" data-sort="email">Email</th>
                    {% for ft in nominee_feedback_types %}<th scope="col" data-sort="{{ ft.name|slugify }}-num">{{ ft.name }}</th>{% endfor %}
                </tr>
            </thead>
            <tbody>
                {% for fb_dict in staterank.list %}
                    <tr>
                        <td>
                            <a href="{% url 'ietf.nomcom.views.view_feedback_nominee' year=year nominee_id=fb_dict.nominee.id %}">
                                {{ fb_dict.nominee.person.first_name }}
                            </a>
                        </td>
                        <td>
                            <a href="{% url 'ietf.nomcom.views.view_feedback_nominee' year=year nominee_id=fb_dict.nominee.id %}">
                                {{ fb_dict.nominee.person.last_name }}
                            </a>
                        </td>
                        <td>
                            <a href="{% url 'ietf.nomcom.views.view_feedback_nominee' year=year nominee_id=fb_dict.nominee.id %}">
                                {{ fb_dict.nominee.email.address }}
                            </a>
                        </td>
                        {% for fbtype_name, fbtype_count, fbtype_newflag in fb_dict.feedback %}
                            <td>
                                {% if fbtype_newflag %}<span class="badge rounded-pill text-bg-success">New</span>{% endif %}
                                {{ fbtype_count }}
                            </td>
                        {% endfor %}
                    </tr>
                {% endfor %}
            </tbody>
            <tfoot>
                <tr>
                    <th scope="row">Totals</th>
                    <td></td>
                    <td></td>
                    {% for fbtype_count in staterank.list|feedback_totals %}
                    <td>
                        {{ fbtype_count }}
                    </td>
                    {% endfor %}
                </tr>
            </tfoot>
        </table>
    {% endfor %}
    <h2 class="mt-5" id="topics">Feedback related to topics</h2>
    <table class="table table-sm table-striped tablesorter">
        <thead>
            <tr>
                <th scope="col" data-sort="topic">Topic</th>
                {% for ft in topic_feedback_types %}<th scope="col" data-sort="{{ ft.name|slugify }}-num">{{ ft.name }}</th>{% endfor %}
            </tr>
        </thead>
        <tbody>
            {% for fb_dict in topics_feedback %}
                <tr>
                    <td>
                        <a href="{% url 'ietf.nomcom.views.view_feedback_topic' year=year topic_id=fb_dict.topic.id %}">
                            {{ fb_dict.topic.subject }}
                        </a>
                    </td>
                    {% for fbtype_name, fbtype_count, fbtype_newflag in fb_dict.feedback %}
                        <td>
                            {% if fbtype_newflag %}<span class="badge rounded-pill text-bg-success">New</span>{% endif %}
                            {{ fbtype_count }}
                        </td>
                    {% endfor %}
                </tr>
            {% endfor %}
        </tbody>
    </table>
    {% if independent_feedback_types %}
        <h2 class="mt-5" id="misc">Feedback not related to Nominees</h2>
        <table class="table table-sm table-striped tablesorter">
            <thead>
                <tr>
                    <th scope="col"></th>
                    {% for ft in independent_feedback_types %}<th scope="col" data-sort="{{ ft.name|slugify }}-num">{{ ft.name }}</th>{% endfor %}
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>
                        <a href="{% url 'ietf.nomcom.views.view_feedback_unrelated' year %}">View feedback not related to nominees</a>
                    </td>
                    {% for count in independent_feedback %}<td>{{ count }}</td>{% endfor %}
                </tr>
            </tbody>
        </table>
    {% endif %}
{% endblock %}